"""测试用例层"""
import unittest

import requests

from tpshop_reg_int import TpShopReigster


# 定义测试类
class TestRegister(unittest.TestCase):
    session = None

    def setUp(self) -> None:
        self.session = requests.Session()
        TpShopReigster.get_verify(self.session)

    # 注册成功
    def test01_register(self):
        data = {"scene": "1", "username": "17615567325", "verify_code": "8888", "password": "123456",
                "password2": "123456"}
        resp = TpShopReigster.register(self.session, data)
        print("注册成功，响应体", resp.json())
        self.assertEqual(200, resp.status_code)
        self.assertEqual(1, resp.json().get("status"))
        self.assertEqual("注册成功", resp.json().get("msg"))

    # 该手机号已注册
    def test02_register(self):
        data = {"scene": "1", "username": "13012345678", "verify_code": "8888", "password": "123456",
                "password2": "123456"}
        resp = TpShopReigster.register(self.session, data)
        print("该手机号已注册，响应体", resp.json())
        self.assertEqual(200, resp.status_code)
        self.assertEqual(-1, resp.json().get("status"))
        self.assertEqual("该手机号已注册", resp.json().get("msg"))

    # 两次密码不一致
    def test03_register(self):
        data = {"username": "18384567523", "verify_code": "8888", "password": "123456",
                "password2": "123321"}
        resp = TpShopReigster.register(self.session, data)
        print("两次密码不一致，响应体", resp.json())
        self.assertEqual(200, resp.status_code)
        self.assertEqual(-1, resp.json().get("status"))
        self.assertEqual("两次密码不一致", resp.json().get("msg"))
